/*
 * Copyright 2007 Matt Jensen
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 */
package org.jtell.internal;

import java.util.Set;

/**
 * <p>
 * <code>MultiMap</code> defines the public interface to a simple map-like structure which allows multiple values to be
 * associated with each key.
 * </p>
 */
public interface MultiMap<K, V>
{
    /**
     * <p>
     * Clear the map.
     * </p>
     */
    void clear();

    /**
     * <p>
     * Get all values which have been associated with a given key value <em>and all of its inherited values</em>.
     * </p>
     *
     * @param key the key value.
     * @return {@link Set} of {@link Object} instances, or <code>null</code> if neither the key value nor any of its
     * inherited values is present as a key in the map.
     */
    Set<V> getAll(K key);

    /**
     * <p>
     * Determine whether the map is empty.
     * </p>
     *
     * @return <code>boolean</code> indicating whether the map is empty.
     */
    boolean isEmpty();

    /**
     * <p>
     * Add a value to the map under a given key.
     * </p>
     *
     * @param key the key under which the value is to be added.
     * @param value the value to add.
     */
    void put(K key, V value);

    /**
     * <p>
     * Remove all values which match a given predicate, under all keys in the map. Each value is passed to the
     * predicate; those for which it returns <code>true</code> will be removed. 
     * </p>
     *
     * @param matcher the predicate.
     */
    void removeAllMatching(Predicate<V> matcher);

    /**
     * <p>
     * Get the number of entries in the map. There is one entry per key--assigning multiple values to a single key does
     * not affect the size as returned by this method.
     * </p>
     *
     * @return <code>int</code> size of the map.
     */
    int size();
}
